<div class="headline">
    <h2>
        <?php echo $this->translate('Exams');?>
    </h2>
    <div class="tabs">
        <?php
        // Render the menu
        echo $this->navigation()
        ->menu()
        ->setContainer($this->navigation)
        ->render();
        ?>
    </div>
</div>

<div class="headline">
    <div class="tabs">
        <?php
        // Render the menu
        echo $this->navigation()
        ->menu()
        ->setContainer($this->subnavigation)
        ->render();
        ?>
    </div>
</div>

<form id="<?php echo $this->form->getAttrib('id');?>" name="<?php echo $this->form->getAttrib('name');?>" enctype="multipart/form-data" action="<?php echo $this->escape($this->form->getAction()) ?>" method="<?php echo $this->escape($this->form->getMethod()) ?>" class="global_form">
    <div>
        <div>
            <h3>
                <?php echo $this->translate($this->form->getTitle()) ?>
            </h3>
            <p class="form-description"><?php echo $this->translate($this->form->getDescription()) ?></p>
            <div class="form-elements">
                <?php if($this->form->getDecorator('FormErrors')) echo $this->form->getDecorator('FormErrors')->setElement($this->form)->render();?>
                <?php if($this->form->getDecorator('FormMessages')) echo $this->form->getDecorator('FormMessages')->setElement($this->form)->render();?>            	
                <?php echo $this->form->title; ?>
                <?php echo $this->form->category_id; ?>
                <?php echo $this->form->description; ?> 
                <?php echo $this->form->photo; ?>
                <?php echo $this->form->is_forever; ?>
                <?php echo $this->form->starttime; ?>
                <?php echo $this->form->endtime; ?> 
                <?php echo $this->form->is_limited; ?> 
                <?php echo $this->form->duration; ?>
                
                <?php echo $this->form->attempts_allowed; ?>
                <?php echo $this->form->question_shuffle; ?>
                <?php echo $this->form->view_correct; ?>
                <?php echo $this->form->view_explanation; ?>
                
                <?php echo $this->form->auth_test; ?>
                <?php echo $this->form->auth_comment; ?>
                
                
                <?php echo $this->form->buttons; ?>
            </div>
         </div>
    </div>
</form>


<?php //echo $this->form->render($this) ?>

<script type="text/javascript">
  en4.core.runonce.add(function(){
	  <?php if(($this->values && $this->form->is_limited->getValue() == 0) || !$this->values):?>
			$('duration-wrapper').hide();
	  <?php endif;?>
	  <?php if(($this->values && $this->form->is_forever->getValue() == 0) || !$this->values):?>
		    $('starttime-wrapper').hide();
		    $('endtime-wrapper').hide();
	  <?php endif;?>
  });
  var cal_starttime_onHideStart = function(){
    // check end date and make it the same date if it's too
    cal_endtime.calendars[0].start = new Date( $('starttime-date').value );
    // redraw calendar
    cal_endtime.navigate(cal_endtime.calendars[0], 'm', 1);
    cal_endtime.navigate(cal_endtime.calendars[0], 'm', -1);
  }
  var cal_endtime_onHideStart = function(){
    // check start date and make it the same date if it's too
    cal_starttime.calendars[0].end = new Date( $('endtime-date').value );
    // redraw calendar
    cal_starttime.navigate(cal_starttime.calendars[0], 'm', 1);
    cal_starttime.navigate(cal_starttime.calendars[0], 'm', -1);
  }
  function changeDuration(obj){
		if(obj.value == 1){
			if($('duration-wrapper'))
				$('duration-wrapper').show();
		}else{
			if($('duration-wrapper'))
				$('duration-wrapper').hide();
		}
  }
  function changeTimeLimit(obj){
		if(obj.value == 1){
				$('starttime-wrapper').show();
				$('endtime-wrapper').show();
		}else{
				$('starttime-wrapper').hide();
				$('endtime-wrapper').hide();
		}
 }
</script>
